<?php
include_once("../includes/common.php");
include_once("../class/User.class.php");
require_once("../islogin.php");

if ($isadmin!=1){
    header('Location: /');
    exit;
}

$menuavatar = !$user_info["message"]["avatar"] ? "/data/avatar/default.jpg" : $user_info["message"]["avatar"];
$pageName = "用户权限";

if(isset($_GET['uid'])&&!isUid($_GET['uid'])){
    exit('uid error');
}

$utype = $user->getUserType($_GET['uid']);
if(isset($_GET['type'])){
    $res = $user->upUserType($_GET['uid'],$_GET['type']);
    $referrer = $_SERVER['HTTP_REFERER'];
    header("Location: $referrer");
    exit();
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>

    <?php require_once('head.php'); ?>

    <link rel="stylesheet" href="/static/css/message.css" />
</head>
<body>

<!--==================== Preloader Start ====================-->
<div class="preloader">
    <div class="loader"></div>
</div>
<!--==================== Preloader End ====================-->

<!--==================== Sidebar Overlay End ====================-->
<div class="side-overlay"></div>
<!--==================== Sidebar Overlay End ====================-->


<?php require_once('menu.php'); ?>
<div class="dashboard-main-wrapper">

    <?php require_once('top_navbar.php'); ?>
    <div class="dashboard-body">
            <!-- My Details Tab start -->
            <div class="tab-pane fade show active" id="pills-details" role="tabpanel" aria-labelledby="pills-details-tab" tabindex="0">
                <div class="card">
                    <div class="card-header border-bottom">
                        <h4 class="mb-4">用户权限</h4>
                    </div>
                    <div class="card-body">
                        <form action="" method="get">
                            <div class="row gy-4">
                                <div class="col-sm-12 col-xs-12">
                                    <label for="fname" class="form-label mb-8 h6">用户 24位 UID</label>
                                    <input type="text" required maxlength="24" value="<?php echo $_GET['uid']?>" name="uid" class="form-control py-11" id="fname" placeholder="输入UID">
                                </div>
                                <div class="col-sm-12 col-xs-12">
                                    <label for="fname" class="form-label mb-8 h6">用户权限</label>
                                    <select id="userRole" name="type" class="form-control py-11">
                                        <option value="0" <?php if ($utype==0){echo 'selected';}?> >机器人</option>
                                        <option value="1"<?php if ($utype==1){echo 'selected';}?> >管理员</option>
                                        <option value="2"<?php if ($utype==2){echo 'selected';}?> >用户</option>
                                        <option value="3"<?php if ($utype==3){echo 'selected';}?> >审核官</option>
                                    </select>
                                    <?php if ($utype==1){?>
                                    <div class="flex-align justify-content-end gap-8 mt-5">
                                        <p for="fname" class="form-label mb-8 h6">管理员用户禁止变动权限！</p>
                                    </div>
                                    <?php }?>
                                </div>
                                <div class="col-12">
                                    <div class="flex-align justify-content-end gap-8">
                                        <button type="submit" class="btn btn-main rounded-pill py-9">修改</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- My Details Tab End -->

    </div>

    <?php require_once('footer.php'); ?>
</div>

<script src="/static/js/message.min.js"></script>
<?php require_once('foot.php'); ?>



</body>
</html>